<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019-01-03
 * Time: 20:39
 */

namespace App\Http\Controllers;


use Illuminate\Http\UploadedFile;

trait UploadFile
{
    /**
     * @param UploadedFile $file
     * @return bool|\Symfony\Component\HttpFoundation\File\File
     */
    public function up(UploadedFile $file)
    {
        if ($file->isValid()) {
            $ext = $file->extension();
            return $file->move(public_path('uploads'), time() . rand() . '.' . $ext);
        } else {
            return false;
        }
    }
}